/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package monkify;

import java.io.Serializable;

/**
 *
 * @author pierre
 */
public class Track implements Cloneable, Serializable {
  public static final long serialVersionUID = 0;

  String uri, name, album, artist, year;
  int x, y;
  int value;

  Track (String uri) {
    this.uri = uri;
  }

  static Track fromMetadata(String metadata) {
    // 0:[uri],1:[name],2:[album],3:[artist],4:[year]
    String[] parts = metadata.split(","); 
    Track track = new Track(parts[0]);
    track.name = parts[1];
    track.album = parts[2];
    track.artist = parts[3];
    track.year = parts[4];
    track.value = 0;
    return track;
  }

  Track place(int x, int y) {
    this.x = x;
    this.y = y;
    return this;
  }

  Track copy() {
    Track copy = new Track(uri);
    copy.name = name;
    copy.album = album;
    copy.artist = artist;
    copy.year = year;
    copy.value = value;
    return copy;
  }

  @Override public int hashCode() { return uri.hashCode(); }
}